package tree;

public class Tree02<E extends Comparable<E>> {
    private Node root;

    class Node {
        E data;
        Node left;
        Node right;

        public Node(E e) {
            data = e;
        }

        public boolean append(E e) {
            if (data.compareTo(e) == 0) {
                return false;
            }
            if (data.compareTo(e) > 0) {
                if (left == null) {
                    left = new Node(e);
                    return true;
                } else {
                    return left.append(e);
                }
            } else {
                if (right == null) {
                    right = new Node(e);
                    return true;
                } else {
                    return right.append(e);
                }
            }
        }

    }
    public boolean add(E e){
        if (root==null){
            root=new Node(e);
            return true;
        }
        return root.append(e);
    }
}
